home *** CD-ROM | disk | FTP | other *** search
/ stazsoftware.com / www.stazsoftware.com.tar / www.stazsoftware.com / futurebasic / sample-code / timeout.sit / Beta Time Out.incl
Text File  |  2005-04-04  |  3KB  |  129 lines

  1. _isBeta = _zTrue
  2.  
  3.  
  4. /*
  5.  
  6.      to use this you will need to do 3 things:
  7.  
  8.           thing 1 - include this file. 
  9.  
  10.           thing 2 - create a file named Beta.glbl and in it place a dummy
  11.                constant like this: _betaTimeOut = 0 [this will be overwritten.]
  12.  
  13.           thing 3 - in should program, call...
  14.  
  15.                #if _isBeta
  16.                  long if system ( _aplFlag )
  17.                   long if fn checkBetaDate
  18.                            if fn StandardAlert(_kAlertNoteAlert, "beta expired", "xxx must now quit", 0, #0) then end else end
  19.                        end if
  20.                  xelse
  21.                   fn resetBetaDate
  22.                  end if
  23.                #endif
  24.  
  25.           you might want to expand on the stop dialog to tell the user
  26.           something more than 'beta expired'. perhaps you will tell them
  27.           where to get a new beta.
  28.  
  29.      now *** RUN *** the file at least once. when you reopen the Beta.glbl
  30.      file, you will see something like this...
  31.  
  32.  
  33.      //file updated on 03/30/05 at 01:56:38
  34.      _betaTimeOut = 0xBE9744D6// expires 4/29/05
  35.      dim as str255 gBetaExpiration
  36.      gBetaExpiration = "Expires 4/29/05"
  37.  
  38.      note that there is an extra global string here [gBetaExpiration] that you 
  39.      may use in an 'about' box to tell your user whne the beta will expire.
  40.  
  41.  
  42.      how this works:
  43.  
  44.      each time you *run* your program during the testing cycle, it
  45.      recreates the beta.glbl file with a new beta date that is 30 days
  46.      beyond the current date. when the file is finally built, it will
  47.      include an expiration date that is hard wired into the code that
  48.      is 30 days from the last day that is used. this can't be changed
  49.      by the user by switching some resource. it is hard-wired into the code.
  50.  
  51.      you check, at some point in your code, to see if the beta date has
  52.      expired and make make an exit if it has. the check is a simple one.
  53.  
  54.      hasExpired = fn checkBetaDate
  55.  
  56.      if hasExpired is non zero then the 30 days has expired.
  57.  
  58.      if you want more or less than 30 days, change the 30 in fn resetBetaDate
  59.      myDateTimeRec.day = myDateTimeRec.day + 30 <----------
  60.  
  61.      ------------------
  62.  
  63.      when you are ready to ship a final product, set _isBeta [above] to _false
  64. */
  65.  
  66.  
  67. #if _isBeta
  68.  
  69. clear local
  70. local fn resetBetaDate
  71. '~'9
  72.  
  73. dim myDateTimeRec       as DateTimeRec
  74. dim @mySeconds          as long
  75. dim as str255 sourceLine(2)
  76. dim betaString          as str255
  77. dim fs                  as fsSpec
  78. dim err                 as OSErr
  79.  
  80. long if _isBeta
  81.  
  82. long if system(_aplFlag) = _false
  83. GetDateTime(mySeconds)
  84. SecondsToDate(mySeconds, myDateTimeRec)
  85. myDateTimeRec.day = myDateTimeRec.day + 30
  86. DateToSeconds (myDateTimeRec, mySeconds)
  87. DateString( mySeconds, _shortDate, betaString, fn GetIntlResource( 0 ) )
  88.  
  89.  
  90. sourceLine(0)  = "_betaTimeOut = 0x"+hex$(mySeconds) + "// expires " + betaString
  91. sourceLine(1)  = "dim as str255 gBetaExpiration"
  92. sourceLine(2)  = "gBetaExpiration = "  +chr$(34) + "Expires " +betaString +chr$(34)
  93.  
  94.  
  95. def open "TEXTFB^e"
  96. open "O",#1,"Beta.glbl",1,system(_aplVol)
  97. print #1,"//file updated on ";date$;" at "time$
  98. print #1,sourceLine(0)
  99. print #1,sourceLine(1)
  100. print #1,sourceLine(2)
  101. close #1
  102.  
  103. end if
  104. end if
  105. end fn
  106.  
  107. clear local
  108. local fn checkBetaDate
  109. '~'9
  110. dim @mySeconds          as long
  111. dim result              as word
  112.  
  113. result = 0
  114. long if _isBeta
  115. long if system(_aplFlag)
  116. GetDateTime(mySeconds)
  117. long if (mySeconds >> 1) > (_betaTimeOut >> 1)
  118. result = _zTrue
  119. end if
  120. end if
  121. end if
  122.  
  123.  
  124.  
  125. end fn = result
  126. #endif
  127.  
  128.  
  129.